package sh4;


import gui.Emu;
import memory.Memory;

public class Bios {
	
	/*
	 * value found on gxemul
	 */
	public static final int  DREAMCAST_ROMFONT_BASE	= 0x00100020;
	
	/*
	 * homebrew rom font from the swirly project
	 */
	public static final byte [] romfont = {
		0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0x40,4,0,0x40,4,0,0x40,4,0,0x40,4,0,0,4,0,0x40,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,10,0,(byte) 0xa0,10,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,5,0,0x50,5,1,(byte)0xf8,10,0,(byte)0xa0,0x3f,1,0x40,0x14,1,0x40,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,4,0,0x40,0x1f,2,0x48,0x24,(byte) 0x81,0x40,0xe,0,0x50,4,(byte)0x82,0x48,0x24,(byte)(byte) 0x81,(byte)0xf0,4,0,0x40,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0x70,(byte) 0x88,(byte) 0x90,(byte)0x89,7,0x20,2,0,0x40,9,(byte) 0xc1,0x22,0x12,0x22,0x1c,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0x18,2,0x40,0x24,1,(byte)0x80,0x10,2,(byte) 0x90,0x45,4,0x20,0x45,3,(byte) 0x88,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0x40,4,0,0x40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x20,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,2,0,0x40,4,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,0x40,4,0x40,0,0,0,0,0,0,0,0x0
		,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0,0,0,0,3,0,0xc,0,0x30,0xc,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0x80,0x66,4,0x20,0x42,0,0x21,4,0x10,(byte) 0x81,0x10,0x10,1,0x10,1,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0xe0,0x61,(byte) 0x88,4,(byte)0x8d,0x41,0x24,0x22,0x42,0x24,0x26,(byte) (byte) 0x81,(byte) 0xb0,(byte) 0x80,0xc,0x10,0x3e,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,(byte) 0x80,8,1,0x40,0x14,2,0x20,0x22,4,0x10,0x7f,4,0x10,(byte) 0x80,(byte) 0x88,8,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0xf,(byte) 0xc0,(byte)0x86,8,0x20,(byte)0x82,8,0x20,(byte)0xfc,8,0x20,(byte)0x82,8,0x20,(byte)0x82,0xf,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0xc0,0x63,4,0x10,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,4,0x10,0x63,1,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0xf,(byte) 0x80,(byte)0x86,8,0x20,(byte) (byte) 0x81,8,0x10,(byte) (byte) 0x81,8,0x10,(byte) (byte) 0x81,8,0x20,(byte)(byte)0x86,0xf,(byte) 0x80,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0xf,(byte) 0xe0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0xfc,8,0,(byte) 0x80,8,0,(byte) 0x80,0xf,(byte) 0xe0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0xf,(byte) 0xe0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0xfc,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0xe0,0x61,(byte)0x84,8,(byte) 0x80,8,0,(byte)0x87,(byte) 0x88,8,(byte) 0x80,(byte)0x84,8,0x63,(byte) (byte) 0x81,(byte) 0xc8,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,8,0x10,(byte) (byte) 0x81,8,0x10,(byte) (byte) 0x81,8,0x10,(byte)0xff,8,0x10,(byte) (byte) 0x81,8,0x10,(byte) (byte) 0x81,8,0x10,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0x40,4,0,0x40,4,0,0x40,4,0,0x40,4,8,0x40,(byte)0x84,7,(byte) 0x80,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,8,0x20,(byte)0x84,8,(byte) 0x80,(byte) 0x90,10,0,(byte) 0xe0,9,0,(byte) 0x88,8,0x40,(byte)0x82,8,0x10,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,0xf,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,8,2,(byte) 0x80,0x2c,6,(byte)0xa0,(byte)0xaa,10,(byte)0x91,0x29,0x12,(byte)0x8a,0x28,(byte)0xa2,(byte)0x84,0x28,0x40,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0xc,0x10,(byte) 0xc1,10,0x10,(byte)0x91,9,0x10,(byte)0x89,8,(byte) 0x90,(byte)0x85,8,0x50,(byte)0x83,0,0x30,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0xc0,0x63,4,0x10,(byte) 0x80,(byte) 0x88,8,(byte) 0x80,(byte) 0x88,8,(byte) 0x80,(byte) (byte)0x84,0x10,0x63,1,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,7,(byte) 0xe0,0x43,4,0x10,0x41,4,0x30,0x7e,4,0,0x40,4,0,0x40,4,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,(byte) 0xe0,0x31,(byte)0x82,8,0x40,0x44,4,0x40,0x44,0x44,0x42,0x42,0x18,0x31,(byte) 0x80,(byte)0xe4,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,7,(byte) 0xe0,0x43,4,0x10,0x41,4,0x20,0x7c,4,0x20,0x41,4,0x10,0x41,4,0x10,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0xc0,0x63,4,0x10,0x40,3,0,0xc,0,0x30,1,4,0x10,0x63,1,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,7,(byte) 0xfc,4,0,0x40,4,0,0x40,4,0,0x40,4,0,0x40,4,0,0x40,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,8,0x40,(byte) (byte)0x84,8,0x40,(byte) (byte)0x84,8,0x40,(byte) (byte)0x84,8,0x40,(byte) (byte)0x84,8,0x21,1,(byte) 0xe0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,4,0x40,0x42,8,0x20,(byte) (byte) 0x81,0x10,0x11,1,0x10,10,0,(byte)0xa0,4,0,0x40,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,8,0x42,(byte) (byte)0x84,0x28,(byte)0xa2,0x4a,0x44,(byte)0xa4,0x4a,0x42,(byte)0xa8,0x2a,(byte)0x82,(byte)0xa8,0x11,1,0x10,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,8,0x40,(byte)0x82,0x10,0x12,0,(byte) 0xc0,0xc,1,0x20,0x21,2,0x10,0x40,(byte) (byte)0x84,8,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,4,0x20,(byte)0x82,8,0x11,1,0x10,10,0,0x40,4,0,0x40,4,0,0x40,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,7,(byte) 0xf0,1,0,0x20,4,0,(byte) 0xc0,8,1,0,0x30,2,0,0x40,7,(byte) 0xf0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0xe,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0xe0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,0,0x10,0,(byte) 0x80,8,0,(byte) 0x80,4,0,0x40,4,0,0x20,2,0,0x20,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,7,0,0x10,1,0,0x10,1,0,0x10,1,0,0x10,1,0,0x10,1,0,0x10,1,0,0x70,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,4,0,(byte)0xa0,0x11,2,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x3f,(byte) 0xc0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0x40,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0x3c,6,0x60,2,3,(byte) 0xe0,0x62,4,0x20,0x66,3,(byte) 0xb0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,0,0x40,4,0,0x5c,6,0x60,0x42,4,0x20,0x42,4,0x20,0x66,5,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0x3c,6,0x60,0x40,4,0,0x40,4,0x20,0x66,3,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0x20,2,0,0x20,0x3a,6,0x60,0x42,4,0x20,0x42,4,0x20,0x66,3,(byte) 0xa0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0x3c,6,0x60,0x42,7,(byte) 0xe0,0x40,4,0,0x66,3,(byte) 0xc0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,(byte) 0x80,0x20,2,0,0x70,2,0,0x20,2,0,0x20,2,0,0x20,2,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0x3a,6,0x60,0x42,4,0x20,0x42,4,0x20,0x66,3,(byte) 0xa0,2,6,0x60,0x3c,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,0,0x40,4,0,0x5c,6,0x60,0x42,4,0x20,0x42,4,0x20,0x42,4,0x20,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,(byte) 0x80,8,0,0,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,8,0,(byte) 0x80,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,1,0,0x10,0,0,0x10,1,0,0x10,1,0,0x10,1,0,0x10,1,0,0x10,1,0,0x60,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,4,0,0x40,4,0,0x44,4,(byte) 0x80,0x50,6,0,0x50,4,(byte) 0x80,0x44,4,0x20,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0
		,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x0};
	
	/*
	 * http://mc.pp.se/dc/syscalls.html from here
	 */
	
	public static final int  GDROM_REQCMD = 0;
	public static final int  GDROM_GETCMDSTAT = 1;
	public static final int  GDROM_EXECSERVER = 2;
	public static final int GDROM_INITSYSTEM = 3;
	public static final int GDROM_GETDRVSTAT = 4;
	public static final int GDROM_G1DMAEND = 5;
	public static final int  GDROM_REQDMATRANS = 6;
	public static final int GDROM_CHECKDMATRANS = 7;
	public static final int GDROM_READABORT = 8;
	public static final int GDROM_RESET = 9;
	public static final int GDROM_CHANGEDATATYPE = 10;

	public static final int  GDROM_CMD_PIOREAD = 16;
	public static final int GDROM_CMD_DMAREAD = 17;
	public static final int GDROM_CMD_GETTOC = 18;
	public static final int GDROM_CMD_GETTOC2 = 19;
	public static final int GDROM_CMD_PLAY = 20;
	public static final int GDROM_CMD_PLAY2 = 21;
	public static final int GDROM_CMD_PAUSE = 22;
	public static final int GDROM_CMD_RELEASE = 23;
	public static final int GDROM_CMD_INIT = 24;
	public static final int GDROM_CMD_SEEK = 27;
	public static final int GDROM_CMD_READ = 28;
	public static final int GDROM_CMD_STOP = 33;
	public static final int GDROM_CMD_GETSCD = 34;
	public static final int GDROM_CMD_GETSES = 35;


	private static Sh4Context sh4 = Emu.sh4cpu;
	
	public static final void handler(int PC){
		System.out.println("BIOS CALLED with argument " + Integer.toHexString(PC));
		//Sh4Context.debugging = true;
		int syscall = PC & 0xffff;
		System.out.println("Syscall " + Integer.toHexString(syscall));
		switch (syscall) {
			// sysinfo
			case 0x0302:
			
			break;
			// rom font
			case 0x100:
				if(sh4.registers[1] == 0){
					sh4.registers[0] = DREAMCAST_ROMFONT_BASE;
				}
			break;
			// flashrom
			case 0x0402:
			break;
			//gdrom (taken from the discontinued dreamcast emulator swirly)
			case 0x200:
				   if(sh4.registers[6] != 0)
					    {
					    System.out.println("Gdrom::hook: r6 != 0 so doing nothing.\n");
					    return;
					   }

					   	switch(sh4.registers[7])
					   		{
							       case GDROM_EXECSERVER:
							      // start executing commands
							      System.out.println("Gdrom: syscall: GDROM_EXECSERVER\n");
							      break;
							        case GDROM_INITSYSTEM:
							      // this is a nop for us
							      System.out.println("Gdrom: syscall: GDROM_INITSYSTEM\n");
							     break;
							      case GDROM_GETDRVSTAT:
							      // get type of disc
							      // r4 = addr of param block
							     // XXX: what is the structure of the param block?
							      //System.out.println("Gdrom: syscall: GDROM_GETDRVSTAT\n");
							      // we'll pretend we have an XA disc
							      //System.out.println("PC is %08x\n", cpu->PC);
							    
							      // CDDA     0x00
							      // CDROM    0x10
							      // CDROM_XA 0x20
							      // CD_CDI   0x30
							     // CD_GDROM (byte) 0x80
							   
							      Memory.write32(sh4.registers[4]+4, 0x20);
							      break;
							        case GDROM_G1DMAEND:
							     System.out.println("Gdrom: syscall: GDROM_G1DMAEND\n");
							      break;
							       case GDROM_REQDMATRANS:
							      System.out.println("Gdrom: syscall: GDROM_REQDMATRANS\n");
							      break;
							        case GDROM_CHECKDMATRANS:
							      System.out.println("Gdrom: syscall: GDROM_CHECKDMATRANS\n");
							      break;
							        case GDROM_READABORT:
							     System.out.println("Gdrom: syscall: GDROM_READABORT\n");
							     break;
							     case GDROM_RESET:
							     System.out.println("Gdrom: syscall: GDROM_RESET\n");
							      break;
							        case GDROM_CHANGEDATATYPE:
							      // sets the format of the disc
							      // we want to know the sector size
							      // param[0]: 0=set, 1=get
							      // param[1]: 8192, for some reason
							      // param[2]: 2048 = mode1, 1024=mode2
							      // param[3]: sector size
							      // r4 = addr of param block
							      System.out.println("Gdrom: syscall: GDROM_CHANGEDATATYPE\n");
							      {
							          sh4.registers[0] = 0;
							      }
							      break;
							        case GDROM_GETCMDSTAT:
							      // checks whether a command has completed?
							      // r4 = command id
							      // r5 = addr of param block
							      // return 1 if still pending
							      // return 2 if done
							      System.out.println("Gdrom: syscall: GDROM_GETCMDSTAT\n");
							      sh4.registers[0] = 2;
							      break;
							        case GDROM_REQCMD:
							      // adds a command to the GDROM command queue?
							      // r4=cmd, r5=addr of param block
							      System.out.println("Gdrom: syscall: GDROM_REQCMD ");
							      switch(sh4.registers[4])
							      {
							      case GDROM_CMD_INIT:
							          System.out.println("GDROM_CMD_INIT");
							          break;
							      case GDROM_CMD_GETTOC2:
							          // param[0] = session
							         // param[1] = pointer to buffer to receive TOC info
							         // TOC structure:
							         // Dword entry[99];
							         // Dword first, last, unknown;
							         // The data track should have a ctrl of 4
							         // ctrl is found in the high 4 bits of track num
							         // LBA is the lower 3 bytes.  To get real sector number
							         // from LBA, add 150.
							         System.out.println("Gdrom: syscall: GDROM_CMD_READTOC");
							         {
							             //Dword session = Memory.read32(sh4.registers[5]);
							             int tocBuffer = Memory.read32(sh4.registers[5]+4);
							             System.out.println("tocBuffer is at" + Integer.toHexString(tocBuffer));
							   
							             /*Toc toc;
							             toc.first = 1 << 16;
							             toc.last = 2 << 16;
							             toc.entry[0] = 0;
							             toc.entry[1] = 0x40000000 + startSector_;
							   			*/
							            // copy it into SH memory
							            // Overlord::copyFromHost(cpu, tocBuffer, (void*)&toc, sizeof(Toc));
							         }
							         break;
							    case GDROM_CMD_PIOREAD:
							         // param[0] = start sector
							        // param[1] = number of sectors
							         // param[2] = pointer to buffer
							         // param[3] = ?
							         System.out.println("GDROM_CMD_READSECTORS");
							         {/*  
							             Dword start = Memory.read32(sh4.registers[5]);
							             Dword count = Memory.read32(sh4.registers[5]+4);
							             Dword buffer = Memory.read32(sh4.registers[5]+8);
							             System.out.println(" start %u count %u buffer %08x sectorSize %d", start, count, buffer, sectorSize);
							             count *= sectorSize;
							             start -= startSector_;
							             start *= sectorSize;
							             System.out.println(" really starting at %u bytes", start);
							           if(cdImage != NULL)
							                 Overlord::load(cdImage, start, count, cpu, buffer);
							             else
							                 System.out.println("cdImage is null");
							            */
							         }
							         break;
							     case GDROM_CMD_DMAREAD:
							    	 /*
							         System.out.println("\nGdrom is attempting to do DMA. We are NOT ready for this.\n");
							         System.out.println("command block: %08x %08x %08x %08x %08x\n",
							                Memory.read32(sh4.registers[5]),    // size
							                Memory.read32(sh4.registers[5]+4),  // count
							                Memory.read32(sh4.registers[5]+8),  // address to do DMA to
							               Memory.read32(sh4.registers[5]+12), // ???
							                Memory.read32(sh4.registers[5]+16)); // address to get DMA from?
							         
							         dmac->startGdromDma(Memory.read32(sh4.registers[5]+8),   // dest
							                             Memory.read32(sh4.registers[5]),     // size
							                             Memory.read32(sh4.registers[5]+4));  // repeat
							   		*/
							      break;				
		}
	}
		}
	}
}
			
